<?php

	class RegisterView{
		

		private $emailAddress = "regemailAddress";
		private $userName = "reguserName";
		private $password = "regpassword";
		private $password2 = "regpassword2";
		private $submit = "registersubmit";
		
		
			
		public function TriedToRegister(){
			if (isset($_POST['registersubmit'])) {
				return TRUE;
			}else {
				return FALSE;
			}			
		}
		
		public function ShowErrors($errors){
			$xhtml = "
			<section id='register' class='body'>
				<article class='block'>
					<h2>Fel i registrering</h2>
					<ul>";
			foreach ($errors as $error) {
				$xhtml .= "<li>$error</li>";
			}
					
			$xhtml .= "
				</ul>
				</article>
			</section>
			";
			
			return $xhtml;
		}
		public function IsDataSet(){
												
			
			if(
				$this->GetUserName() === "" &&
				$this->GetPassword() === "" &&
				$this->GetPassword2() === "" &&
				$this->GetEmailAddress() == ""
			){				
				return FALSE;
			}
			return TRUE;
		}
		
		public function comparePasswords(){
			if($this->GetPassword() === $this->GetPassword2()){
				return TRUE;
			}		
			return FALSE;
		}
		
		public function GetEmailAddress(){
			return $_POST[$this->emailAddress];
		}
		public function GetUserName(){
			return $_POST[$this->userName];
		}
		public function GetPassword(){
			return $_POST[$this->password];
		}
		public function GetPassword2(){
			return $_POST[$this->password2];
		}
		
		public function DoRegisterForm(){
			return "
			<section id='register' class='body'>
			<article class='block'>
			<h2>Registrera ny användare</h2>
			<fieldset>
	<form method='post'>
		<label for='last_name'>Email</label>
		<input type='text' id='$this->emailAddress' name='$this->emailAddress'/>
		
		<label for='email_address'>Användarnamn</label>
		<input type='text' id='$this->userName' name='$this->userName'/>		
		
		<label for='email_address'>Lösenord</label>
		<input type='text' id='$this->password' name='$this->password'/>
		
		<label for='email_address'>Lösenord</label>
		<input type='text' id='$this->password2' name='$this->password2'/>
		
		<br />
		<input type='submit' id='registersubmit' name='registersubmit' />
	</form>
</fieldset>
</article>
</section>
			
			";
		}
	}
